package com.mytest.provider.fm.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: llq
 * @Date: 2020/5/9
 */
@Controller
public class IndexController {


    /**
     * 路由 /index
     * 返回 index 这里默认配置自动映射到 templages/index
     * */
    @RequestMapping("/index")
    public String index(Model model){
        model.addAttribute("welcome","王司徒");


        model.addAttribute("name","王朗");
        //gender:性别，1：男；0：女；
        model.addAttribute("gender",1);

        List<Map<String,Object>> friends =new ArrayList<Map<String,Object>>();
        Map<String,Object> friend = new HashMap<String,Object>();
        friend.put("name", "张三");
        friend.put("age", 20);
        friends.add(friend);
        friend = new HashMap<String,Object>();
        friend.put("name", "李四");
        friend.put("age", 22);
        friends.add(friend);
        model.addAttribute("friends",friends);
        return "index";
    }
}
